﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Adf.Core.Entity;
using Adf.Core.Util;
using Adf.FrameWork.Interface.Entity;
using CYQ.Data.Table;
using Test.Service;

namespace WebApplication1.Controllers
{
    public class HomeController : Controller
    {
        /// <summary>
        /// 登录页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Login()
        {

            return View();
        }

        /// <summary>
        /// 验证登录
        /// </summary>
        /// <returns></returns>
        public ActionResult CheckLogin()
        {
            ExeMsgInfo exeMsgInfo = new ExeMsgInfo();
            String sUserCode = RequestHelper.GetFormString("usercode");
            String sPassWord = RequestHelper.GetFormString("PassWord");
            exeMsgInfo = TestService.Instance().Login().CheckUserLogin(sUserCode, sPassWord);
            return Json(exeMsgInfo);
        }

        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>

        public ActionResult Index()
        {

            int pageCount = 1;
            int recordCount = 0;
            PagerInfo curPagerInfo = new PagerInfo();
            curPagerInfo.PageIndex = RequestHelper.GetQueryString("p", 1);
            curPagerInfo.PageSize = RequestHelper.GetQueryString("ps", 10);

            //排序
            String sOrderBy = Server.UrlDecode(RequestHelper.GetQueryString("OrderBy"));



            String sUserCode = RequestHelper.GetQueryString("usercode");
            MDataRow drUser = TestService.Instance().User().GetEntityWithUserCode(sUserCode);
            String sOrgCode = drUser.Get("orgcode", "");
            MDataRow drOrg = TestService.Instance().Org().GetEntityWithOrgCode(sOrgCode);
            MDataTable dtUser= TestService.Instance().User().GetList(curPagerInfo.PageIndex, curPagerInfo.PageSize, sOrderBy, ref recordCount, ref pageCount);
            ViewBag.dtUser = dtUser;
            ViewBag.drOrg = drOrg;
            ViewBag.drUser = drUser;
            return View();
        }




        public ActionResult AddUser()
        {

            return View();
        }





    }
}